//
//  PhotoSerial.h
//  XPhoto
//
//  Created by baboy on 2019/6/18.
//  Copyright © 2019 baboy. All rights reserved.
//

#import "Model.h"
#import "SearchArgs.h"
#import "User.h"
NS_ASSUME_NONNULL_BEGIN
#define API_SERIAL_CREATE       @"serial_add"
#define API_SERIAL_UPDATE       @"serial_update"
#define API_SERIAL_UPDATE_COVER @"serial_update"
#define API_SERIAL_SEARCH       @"serial_search"
#define API_SERIAL_SEARCH_TAGS  @"serial_search_tags"

@class PostSerialSearchArgs;

@interface PostSerial : Model
@property(nonatomic, assign) NSInteger id;
@property(nonatomic, assign) NSInteger type;
@property(nonatomic, strong) NSString *title;
@property(nonatomic, strong) NSString *lat;
@property(nonatomic, strong) NSString *lng;
@property(nonatomic, strong) NSString *addr;
@property(nonatomic, strong) NSString *intro;
@property(nonatomic, strong) NSString *cover;
@property(nonatomic, strong) NSString *coverThumb;
@property(nonatomic, assign) NSInteger itemCount;
@property(nonatomic, assign) NSInteger postCount;
@property(nonatomic, assign) NSInteger viewCount;
@property(nonatomic, assign) NSInteger likeCount;
@property(nonatomic, assign) NSInteger shareCount;
@property(nonatomic, assign) NSInteger commentCount;
@property(nonatomic, strong) NSDate *createTime;
@property(nonatomic, strong) NSDate *updateTime;
@property(nonatomic, strong) User *user;



+ (id)createPostSerial:(PostSerial*)serial withCallback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;
+ (id)createPostSerial:(PostSerial*)serial withCover:(PhotoAsset*)photoAsset withCallback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;
+ (id)updatePostSerial:(PostSerial*)serial withCallback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;

+ (id)search:(PostSerialSearchArgs *)args withCallback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;
+ (id)searchTagsWithSerialId:(NSInteger)serialId withCallback:(nullable void (^)(id _Nonnull task, id _Nullable json,  NSError * _Nullable error))callback;
+ (id)updateCover:(PhotoAsset *)photoAsset
forSerial:(NSInteger)serialId
         photoUploadProgress:(nullable void(^)(NSString *key, float p))progress
         callback:(void (^)(id _Nonnull, id _Nullable, NSError * _Nullable))callback;

+ (id)  uploadCover:(PhotoAsset *)photoAsset
photoUploadProgress:(void(^)(NSString *key, float p))progress
         callback:(void (^)(id _Nonnull, id _Nullable, NSError * _Nullable))callback;
@end

@interface PostSerialSearchArgs : SearchArgs
@property(nonatomic, strong) NSNumber *uid;
@end
NS_ASSUME_NONNULL_END
